<template>
    <div class="index-wrapper">
        <ul>
            <li class="blog-wrapper" @click="goDetail(items.id)" v-for="(items, index) in list" :key="index">
                <p class="blog-time">{{ items.time }}</p>
                <h3 class="blog-title">{{ items.title }}</h3>
                <div class="blog-content text_overflow" v-html="items.content"></div>
                <div class="read-more">阅读全文</div>
                <div class="blog-tag">
                    <ul>
                        <li v-for="(item, index1) in items.icon" :key="index1" @click.stop="goTags(item)">
                            {{ item }}
                        </li>
                    </ul>
                </div>
            </li>
        </ul>
    </div>
</template>

<script>
export default {
    data() {
        return {
            list: [],
        };
    },
    methods: {
        goDetail(v) {
            this.$router.push("/Details?id=" + v);
        },
        goTags(v) {
            this.$router.push("/tag?name=" + v);
        },
        getList(v) {
            let _this = this;
            if (v) {
                let data = { title: v, };
                this.$axios.post(this.$api.searchList, data).then(function (res) { _this.list = res.data.data || []; });
            } else {
                this.$axios.get(this.$api.list).then(function (res) { _this.list = res.data.data || []; });
            }
        },
    },
};
</script>

<style scoped>
.index-wrapper {
    max-width: 960px;
    margin: 30px auto 40px;
}
.blog-wrapper {
    margin-bottom: 30px;
    padding: 12px 12px 0;
    background: #fff;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(151, 151, 151, 0.58);
}
.blog-time {
    line-height: 24px;
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: bold;
    color: #727272;
    overflow: hidden;
}
.blog-title {
    margin-bottom: 15px;
    font-size: 24px;
    line-height: 32px;
    color: #3f51b5;
}
.blog-content {
    word-break: break-all;
    padding-bottom: 20px;
    line-height: 1.8;
    max-height: 200px;
    overflow-y: auto;
}
.blog-more {
    display: inline-block;
    padding: 0 6px;
    font-weight: 500;
    color: #3f51b5 !important;
    border: none !important;
    border-radius: 3px;
}
.blog-tag {
    position: relative;
    margin: 0 -12px;
    padding: 12px 10px 8px;
    border-top: 1px solid #ddd;
}
.blog-tag li {
    display: inline-block;
    margin: 0 8px 8px 0;
    border-radius: 2px;
    background: #8bc34a;
    padding: 0 16px;
    line-height: 28px;
    color: rgba(255, 255, 255, 0.8);
}
.read-more {
    margin-bottom: 10px;
    color: #fff;
    display: inline-block;
    padding: 4px 8px;
    background: rgb(137, 163, 235);
    border-radius: 4px;
    margin-top: 30px;
}
.read-more:hover {
    cursor: pointer;
}
</style>